# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect %s -verify-machineinstrs -o - -regbankselect-fast | FileCheck -check-prefix=FAST %s
# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect %s -verify-machineinstrs -o - -regbankselect-greedy | FileCheck -check-prefix=GREEDY %s

---
name: sadde_s32_sss
legalized: true

body: |
  bb.0:
    liveins: $sgpr0, $sgpr1, $sgpr2
    ; FAST-LABEL: name: sadde_s32_sss
    ; FAST: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; FAST: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; FAST: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
    ; FAST: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 0
    ; FAST: [[ICMP:%[0-9]+]]:sgpr(s32) = G_ICMP intpred(eq), [[COPY2]](s32), [[C]]
    ; FAST: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[ICMP]](s32)
    ; FAST: [[ZEXT:%[0-9]+]]:sgpr(s32) = G_ZEXT [[TRUNC]](s1)
    ; FAST: [[SADDE:%[0-9]+]]:sgpr(s32), [[SADDE1:%[0-9]+]]:sgpr(s32) = G_SADDE [[COPY]], [[COPY1]], [[ZEXT]]
    ; FAST: [[TRUNC1:%[0-9]+]]:sgpr(s1) = G_TRUNC [[SADDE1]](s32)
    ; GREEDY-LABEL: name: sadde_s32_sss
    ; GREEDY: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; GREEDY: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; GREEDY: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
    ; GREEDY: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 0
    ; GREEDY: [[ICMP:%[0-9]+]]:sgpr(s32) = G_ICMP intpred(eq), [[COPY2]](s32), [[C]]
    ; GREEDY: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[ICMP]](s32)
    ; GREEDY: [[ZEXT:%[0-9]+]]:sgpr(s32) = G_ZEXT [[TRUNC]](s1)
    ; GREEDY: [[SADDE:%[0-9]+]]:sgpr(s32), [[SADDE1:%[0-9]+]]:sgpr(s32) = G_SADDE [[COPY]], [[COPY1]], [[ZEXT]]
    ; GREEDY: [[TRUNC1:%[0-9]+]]:sgpr(s1) = G_TRUNC [[SADDE1]](s32)
    %0:_(s32) = COPY $sgpr0
    %1:_(s32) = COPY $sgpr1
    %2:_(s32) = COPY $sgpr2
    %3:_(s32) = G_CONSTANT i32 0
    %4:_(s1) = G_ICMP intpred(eq), %2, %3
    %5:_(s32), %6:_(s1) = G_SADDE %0, %1, %4
...

---
name: sadde_s32_vss
legalized: true

body: |
  bb.0:
    liveins: $vgpr0, $sgpr0, $sgpr1
    ; FAST-LABEL: name: sadde_s32_vss
    ; FAST: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
    ; FAST: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; FAST: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; FAST: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 0
    ; FAST: [[ICMP:%[0-9]+]]:sgpr(s32) = G_ICMP intpred(eq), [[COPY2]](s32), [[C]]
    ; FAST: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[ICMP]](s32)
    ; FAST: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY1]](s32)
    ; FAST: [[COPY4:%[0-9]+]]:vcc(s1) = COPY [[TRUNC]](s1)
    ; FAST: [[SADDE:%[0-9]+]]:vgpr(s32), [[SADDE1:%[0-9]+]]:vcc(s1) = G_SADDE [[COPY]], [[COPY3]], [[COPY4]]
    ; GREEDY-LABEL: name: sadde_s32_vss
    ; GREEDY: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
    ; GREEDY: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; GREEDY: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; GREEDY: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 0
    ; GREEDY: [[ICMP:%[0-9]+]]:sgpr(s32) = G_ICMP intpred(eq), [[COPY2]](s32), [[C]]
    ; GREEDY: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[ICMP]](s32)
    ; GREEDY: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY1]](s32)
    ; GREEDY: [[COPY4:%[0-9]+]]:vcc(s1) = COPY [[TRUNC]](s1)
    ; GREEDY: [[SADDE:%[0-9]+]]:vgpr(s32), [[SADDE1:%[0-9]+]]:vcc(s1) = G_SADDE [[COPY]], [[COPY3]], [[COPY4]]
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $sgpr0
    %2:_(s32) = COPY $sgpr1
    %3:_(s32) = G_CONSTANT i32 0
    %4:_(s1) = G_ICMP intpred(eq), %2, %3
    %5:_(s32), %6:_(s1) = G_SADDE %0, %1, %4
...
---
name: sadde_s32_ssv
legalized: true

body: |
  bb.0:
    liveins: $sgpr0, $sgpr1, $vgpr0
    ; FAST-LABEL: name: sadde_s32_ssv
    ; FAST: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; FAST: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; FAST: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
    ; FAST: [[TRUNC:%[0-9]+]]:vgpr(s1) = G_TRUNC [[COPY2]](s32)
    ; FAST: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
    ; FAST: [[COPY4:%[0-9]+]]:vgpr(s32) = COPY [[COPY1]](s32)
    ; FAST: [[COPY5:%[0-9]+]]:vcc(s1) = COPY [[TRUNC]](s1)
    ; FAST: [[SADDE:%[0-9]+]]:vgpr(s32), [[SADDE1:%[0-9]+]]:vcc(s1) = G_SADDE [[COPY3]], [[COPY4]], [[COPY5]]
    ; GREEDY-LABEL: name: sadde_s32_ssv
    ; GREEDY: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; GREEDY: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; GREEDY: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
    ; GREEDY: [[TRUNC:%[0-9]+]]:vgpr(s1) = G_TRUNC [[COPY2]](s32)
    ; GREEDY: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
    ; GREEDY: [[COPY4:%[0-9]+]]:vgpr(s32) = COPY [[COPY1]](s32)
    ; GREEDY: [[COPY5:%[0-9]+]]:vcc(s1) = COPY [[TRUNC]](s1)
    ; GREEDY: [[SADDE:%[0-9]+]]:vgpr(s32), [[SADDE1:%[0-9]+]]:vcc(s1) = G_SADDE [[COPY3]], [[COPY4]], [[COPY5]]
    %0:_(s32) = COPY $sgpr0
    %1:_(s32) = COPY $sgpr1
    %2:_(s32) = COPY $vgpr0
    %3:_(s1) = G_TRUNC %2
    %4:_(s32), %5:_(s1) = G_SADDE %0, %1, %3
...

---
name: sadde_s32_vvs
legalized: true

body: |
  bb.0:
    liveins: $vgpr0, $vgpr1, $sgpr0
    ; FAST-LABEL: name: sadde_s32_vvs
    ; FAST: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
    ; FAST: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
    ; FAST: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; FAST: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY2]](s32)
    ; FAST: [[COPY3:%[0-9]+]]:vcc(s1) = COPY [[TRUNC]](s1)
    ; FAST: [[SADDE:%[0-9]+]]:vgpr(s32), [[SADDE1:%[0-9]+]]:vcc(s1) = G_SADDE [[COPY]], [[COPY1]], [[COPY3]]
    ; GREEDY-LABEL: name: sadde_s32_vvs
    ; GREEDY: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
    ; GREEDY: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY $vgpr1
    ; GREEDY: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; GREEDY: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY2]](s32)
    ; GREEDY: [[COPY3:%[0-9]+]]:vcc(s1) = COPY [[TRUNC]](s1)
    ; GREEDY: [[SADDE:%[0-9]+]]:vgpr(s32), [[SADDE1:%[0-9]+]]:vcc(s1) = G_SADDE [[COPY]], [[COPY1]], [[COPY3]]
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %2:_(s32) = COPY $sgpr0
    %3:_(s1) = G_TRUNC %2
    %4:_(s32), %5:_(s1) = G_SADDE %0, %1, %3
...

---
name: sadde_s32_sss_noscc
legalized: true

body: |
  bb.0:
    liveins: $sgpr0, $sgpr1, $sgpr2
    ; FAST-LABEL: name: sadde_s32_sss_noscc
    ; FAST: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; FAST: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; FAST: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
    ; FAST: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY2]](s32)
    ; FAST: [[ZEXT:%[0-9]+]]:sgpr(s32) = G_ZEXT [[TRUNC]](s1)
    ; FAST: [[SADDE:%[0-9]+]]:sgpr(s32), [[SADDE1:%[0-9]+]]:sgpr(s32) = G_SADDE [[COPY]], [[COPY1]], [[ZEXT]]
    ; FAST: [[TRUNC1:%[0-9]+]]:sgpr(s1) = G_TRUNC [[SADDE1]](s32)
    ; GREEDY-LABEL: name: sadde_s32_sss_noscc
    ; GREEDY: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
    ; GREEDY: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
    ; GREEDY: [[COPY2:%[0-9]+]]:sgpr(s32) = COPY $sgpr2
    ; GREEDY: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY2]](s32)
    ; GREEDY: [[ZEXT:%[0-9]+]]:sgpr(s32) = G_ZEXT [[TRUNC]](s1)
    ; GREEDY: [[SADDE:%[0-9]+]]:sgpr(s32), [[SADDE1:%[0-9]+]]:sgpr(s32) = G_SADDE [[COPY]], [[COPY1]], [[ZEXT]]
    ; GREEDY: [[TRUNC1:%[0-9]+]]:sgpr(s1) = G_TRUNC [[SADDE1]](s32)
    %0:_(s32) = COPY $sgpr0
    %1:_(s32) = COPY $sgpr1
    %2:_(s32) = COPY $sgpr2
    %3:_(s1) = G_TRUNC %2
    %4:_(s32), %5:_(s1) = G_SADDE %0, %1, %3
...
